{% extends 'main_hub/search_base.html' %}

{% block title %}
    搜索
{% endblock %}

{% block content %}
    <div class="container-fluid">
        {#  搜索直播 #}
        <div class="row justify-content-center">
            {% for live in all_live.object_list %}
                <div class="col-auto" style="padding-bottom: 10px; width: 300px">
                    <div class="card" style="width: 270px;">
                            <a href="{% url 'play_live' %}?room_num={{ live.number }}" target="_blank">
                                <img src="{{ MEDIA_URL }}{{ live.image }}" class="card-img-top" alt="..."
                                     style="width: 270px;height: 168px;max-width: 100%;">
                            </a>
                        <div class="card-body">
                            <div class="row">
                                <div class="col-8">
                                    <p class="card-text" style="font-weight: bold">
                                        <a href="{% url 'play_live' %}?room_num={{ live.number }}"  style="color: black">
                                            <span class="d-inline-block text-truncate"
                                                  style="max-width: 150px;">
                                            {{ live.name }}</span>
                                        </a>
                                    </p>
                                </div>
                                <div class="col-4  align-self-center text-right">
                                    <p class="card-text" style="font-size: 10px">
                                        <a href="{% url 'son_live' %}?type={{ live.label.father_label.id }}&son_type={{ live.label.id }}"
                                           class="text-secondary" target="_blank">
                                            <span class="d-inline-block text-truncate"
                                                  style="max-width: 150px;">
                                        {{ live.label }}</span>
                                        </a>
                                    </p>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-8 align-self-center">
                                    <p class="card-text" style="font-size: 10px"><a
                                            href="{% url 'detail_user' %}?username={{ live.user.username }}"
                                            target="_blank"
                                            style="text-decoration: none"
                                            class="text-secondary">{{ live.user }}</a>
                                    </p>
                                </div>
                                <div class="col-4 text-right">
                                    <p class="card-text text-secondary" style="font-size: 10px">
                                        <i class="bi bi-people"></i>&nbsp; {{ live.hot_num }}
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            {% endfor %}
        </div>

        {#        分页#}
        <div class="row justify-content-center">
            <div class="col-auto" style="margin-top: 50px">
                <nav aria-label="Page navigation example">
                    <ul class="pagination" style="right:500px">
                        {% if all_live.has_previous %}
                            <li class="page-item">
                                <a href="?{{ all_live.previous_page_number.querystring }}"
                                   class="page-link" aria-label="Previous">
                                    上一页
                                </a>
                            </li>
                        {% endif %}
                        {% for page in all_live.pages %}
                            {% if page %}
                                {% ifequal page all_live.number %}
                                    <li class="page-item">
                                        <a class="page-link" href="?{{ page.querystring }}">{{ page }}</a>
                                    </li>
                                {% else %}
                                    <li>
                                        <a class="page-link page" href="?{{ page.querystring }}">{{ page }}</a>
                                    </li>
                                {% endifequal %}
                            {% else %}
                                <li class="none">...</li>
                            {% endif %}
                        {% endfor %}
                        {% if all_live.has_next %}
                            <li class="page-item">
                                <a href="?{{ all_live.next_page_number.querystring }}" class="page-link"
                                   aria-label="Next">下一页</a>
                            </li>
                        {% endif %}
                    </ul>
                </nav>
            </div>
        </div>
    </div>

{% endblock %}